﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using XiaofangExam.ServiceApi;

namespace XiaofangExam
{
    public partial class Form4 : Form
    {
        private string timu = "";
        private TData<List<ShitiEntity>> data;
        public Form4(string timu, TData<List<ShitiEntity>> _data)
        {
            InitializeComponent();
            this.timu = timu;
            this.data = _data;
        }
        public class Win32
        {

            public const Int32 AW_HOR_POSITIVE = 0x00000001;

            public const Int32 AW_HOR_NEGATIVE = 0x00000002;

            public const Int32 AW_VER_POSITIVE = 0x00000004;

            public const Int32 AW_VER_NEGATIVE = 0x00000008;

            public const Int32 AW_CENTER = 0x00000010;

            public const Int32 AW_HIDE = 0x00010000;

            public const Int32 AW_ACTIVATE = 0x00020000;

            public const Int32 AW_SLIDE = 0x00040000;

            public const Int32 AW_BLEND = 0x00080000;

            [DllImport("user32.dll", CharSet = CharSet.Auto)]

            public static extern bool AnimateWindow(

                IntPtr hwnd,  // handle  to window  

                int dwTime,  // duration  of animation  

                int dwFlags  // animation type  

            );

            [DllImport("user32.dll", CharSet = CharSet.Auto)]

            public static extern bool SetWindowPos(

                IntPtr hwnd,

                int hWndInsertAfter,

                int x,

                int y,

                int cx,

                int cy,

                int wFlags

            );

            /// <summary>
            /// 键盘事件
            /// </summary>
            /// <param name="bVk"> virtual-key code</param>
            /// <param name="bScan">hardware scan code</param>
            /// <param name="dwFlags"> flags specifying various function options</param>
            /// <param name="dwExtraInfo"> additional data associated with keystroke</param>
            [DllImport("user32.dll")]
            public static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);
        }

        private void Form4_Load(object sender, EventArgs e)
        {
            Win32.SetWindowPos(this.Handle, 0, Screen.PrimaryScreen.Bounds.Width - this.Width - 10, Screen.PrimaryScreen.Bounds.Height - this.Height - 30 - 10, 50, 50, 1);//设置弹出位置
            if (data != null && data.Total > 0)
            {
                this.label1.Text = data.Data[0].TiMu;
                this.label4.Text = data.Data[0].Daan + "\r\n" + data.Data[0].DaanContent;
                //this.richTextBox1.Text = data.Data[0].Daan + "\r\n" + data.Data[0].DaanContent;
            }
            else
            {
                this.label1.Text = timu;
                this.label4.Text = "未找到答案";
            }
        }
    }
}
